package com.thewaybetter.modules.client.composites;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.thewaybetter.modules.client.model.SlimIdea;

public class IdeaPanel extends Composite {

	final Label lblIdea = new Label();
	final HTML htmlIdea = new HTML();
	final FlowPanel container = new FlowPanel();
	final VerticalPanel vp = new VerticalPanel();
	final VerticalPanel vpForm = new VerticalPanel();
	final TextBox title = new TextBox();
	final TextArea content = new TextArea();
	private SlimIdea idea;
	
	public IdeaPanel(SlimIdea i) {
		changeIdea(i);
		container.setStyleName("idea-Panel");
		initWidget(container);
		
	}
	
	private void showIdea(){
		DockPanel dock = new DockPanel();
		dock.add(lblIdea,DockPanel.CENTER);
		dock.add(htmlIdea,DockPanel.SOUTH);
		//Button btn = new Button("*");
		//dock.add(btn,DockPanel.EAST);
		vp.add(dock);
		container.add(vp);
		container.setHeight("80");
		lblIdea.addStyleName("lblIdea");
	}
	
	public void setLabel(Label newLbl){
		lblIdea.setText(newLbl.getText());
	}
	
	public void setLabel(String newLbl){
		lblIdea.setText(newLbl);
	}
	
	public void setHtml(HTML html){
		htmlIdea.setHTML(html.getHTML());
	}
	
	public void setHtml(String html){
		htmlIdea.setHTML(html);
	}
	
	public void changeIdea(SlimIdea newIdea){
		setLabel(newIdea.getTitle());
		setHtml(newIdea.getContent());
		showIdea();
	}
	
	public SlimIdea getIdea(){
		return idea;
	}
	
	
	
}
